package cn.rubintry.bug.hunting.adapter

import android.content.Context
import android.graphics.Color
import android.view.ViewGroup
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import cn.rubintry.bug.hunting.R
import cn.rubintry.bug.hunting.pojo.ArticleModel
import com.blankj.utilcode.util.ShadowUtils
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder

class ArticleListAdapter(private val mData: MutableList<ArticleModel>) : BaseQuickAdapter<ArticleModel, QuickViewHolder>(mData) {



    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: ArticleModel?) {
        // 设置item数据
        holder.getView<TextView>(R.id.tvArticleTitle).setText(item?.title)
        holder.getView<TextView>(R.id.tvArticleSubTitle).setText(item?.subTitle)
        val constraintLayout = holder.getView<ConstraintLayout>(R.id.articleItemContainer)
//        if(position == 0){
//            val layoutParams = constraintLayout.layoutParams
//            if(layoutParams is MarginLayoutParams){
//                layoutParams.topMargin = SizeUtils.dp2px(20f)
//                constraintLayout.layoutParams = layoutParams
//            }
//        }
        ShadowUtils.apply(constraintLayout , ShadowUtils.Config().setShadowRadius(40f).setShadowColor(Color.parseColor("#11000000")).setShadowSize(30))
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_home_article , parent)
    }
}